package fudan.se.project.service.infrastructure.entity.conference.role;

import fudan.se.project.domain.User;
import fudan.se.project.domain.conference.Conference;
import fudan.se.project.domain.conference.role.Author;
import fudan.se.project.repository.entity.conference.role.AuthorRepository;
import fudan.se.project.service.infrastructure.base.IEntityService;
import org.springframework.stereotype.Service;

import java.util.Collection;

@Service
public class AuthorService implements IEntityService<Author> {


    private final AuthorRepository authorRepository;

    public AuthorService(AuthorRepository authorRepository) {
        this.authorRepository = authorRepository;
    }

    public Author findByUserAndConference(User userAuthor, Conference conference) {
        return this.authorRepository.findByUserAndConference(userAuthor, conference);
    }

    @Override
    public Author findById(long id) {
        return authorRepository.findById(id);
    }

    @Override
    public Author save(Author author) {
        return authorRepository.save(author);
    }

    @Override
    public Iterable<Author> saveAll(Collection<Author> authors) {
        return authorRepository.saveAll(authors);
    }
}
